<template>
  <div class="cell-item">
    <LabelRow v-on:onMore="onMore" v-bind:label="label" text="更多>>"></LabelRow>
    <ul class="cell-ul">
      <li @click="clickList" v-for="(item,index) in dataList" :key="index">
        <div class="parent-img">
          <img src="../../assets/pigeonholes/trumpet_icon.png" alt>
        </div>
        <div class="text-over flex flex1">
          <h4>「{{item.event_name||'-'}}」</h4>
          <div>{{item.content||'-'}}</div>
        </div>
        <div class="right">{{getTimeStr(item.handle_time)||'-'}}</div>
      </li>
      <div v-if="!dataList.length" class="no-data">
        <img src="../../assets/no-data.png" alt>
      </div>
    </ul>
  </div>
</template>
<script>
import LabelRow from "../common/labelRow.vue";
import { sortingEventinfoQueryBrandMsgPage } from "../../config/api.js";
import Pubsub from "../../utils/pubsub";
import { getTimeStr,getCookie} from "../../utils";

export default {
  components: {
    LabelRow
  },
  data() {
    return {
      label: {
        url: require("../../assets/pigeonholes/message_icon.png"),
        label: "消息中心"
      },
      dataList: [],
      getTimeStr,
      request: {
        pageNum: 1,
        pageSize: 10,
        dealUnitCode:getCookie("department")&&JSON.parse(getCookie("department")).id,//机构编码
      },
    };
  },
  methods: {
    onMore() {
      console.log("onMore");
    },
    clickList() {
      console.log("clickList");
    },

    getList() {
      sortingEventinfoQueryBrandMsgPage(this.request).then((res = {}) => {
        this.dataList = res.rows;
      });
    }
  },
  created() {
    this.getList();
    this.pubsub_token1 = Pubsub.subscribe("MAKE_REMIND", () => {
      this.getList();
    });
  },
  destroyed() {
    this.pubsub_token1 && Pubsub.unsubscribe(this.pubsub_token1);
  }
};
</script>

<style lang="scss" scoped>
@import "../../css/unifyAcceptWorkbench.scss";
.cell-ul {
  li {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    cursor: pointer;
    .parent-img {
      margin-right: 20px;
      img {
        width: 20px;
      }
    }
	.text-over{
		flex-direction: column;
	}
    .right {
      color: #999;
    }
  }
}
</style>
